import type {
  AxiosRequestConfig,
  AxiosResponse,
  InternalAxiosRequestConfig,
  AxiosRequestHeaders
} from 'axios'

// 6.定义自定义拦截器类型
export interface YXInterceptors<T = AxiosResponse> {
  requestSuccessFn?: (
    config: InternalAxiosRequestConfig
  ) => InternalAxiosRequestConfig
  requestFailureFn?: (err: any) => any
  responseSuccessFn?: (res: T) => T
  responseFailureFn?: (err: any) => any
}

export interface YXRequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
  headers?: AxiosRequestHeaders
  interceptors?: YXInterceptors<T>
}
